Drupal.behaviors.smsvidya_register = function(){
  
  /* Login form user name pass word start*/
  var uname = $('form#user-login-form input#edit-name');
  if ($(uname).val()==="") {
    $(uname).val('Type mobile number / email ID');
  } 
  $(uname).focus(function(){
	if (uname.val() == 'Type mobile number / email ID') {
		$(uname).val('');
    }
  });
  $(uname).blur(function(){
	if (uname.val()==="") {
		$(uname).val('Type mobile number / email ID');
	}
  });

var s = Drupal.settings.argument;

if(s!='user'){
$('div#edit-pass-wrapper').html("<input style='color: #fff' type='text' class='form-text required' name='fakepassword' id='fakepassword' value='Type Password'/>");
}
$('#fakepassword').focus(function(){
     
	$('div#edit-pass-wrapper').html("<input type='password' class='form-text required' size='15' maxlength='60' id='edit-pass' name='pass'>");
    
});
	



 /* if ($(pass).val() === "") {
	   $(pass).val('Type password');
   }
  if($(pass).val() == "Type password") {			 
	 if($(pass).length > 0){	
		document.getElementById('edit-pass').type = 'text';
	  }
   }else{
	  if($(pass).length > 0){	
		document.getElementById('edit-pass').type = 'password';
	   }  
	}
				   
	$(pass).focus(function(){
	  if (pass.val() == 'Type password') {
		$(pass).val('');
		if($(pass).length > 0){	
		  document.getElementById('edit-pass').type = 'password';
		}
	   }
	});
	$(pass).blur(function(){
	  if (pass.val()==="") {
		if($(pass).length > 0){					
		  document.getElementById('edit-pass').type = 'text';
		}
		$(pass).val('Type password');						
	  }
	});*/

  /* End Login form user name pass word*/

  //clearing default values on click
  $('div#user-login-form input#edit-submit').click(function(){
		var uname = $('#edit-name');
	
		var pass = $('#edit-pass');
		if (uname.val() == 'Type mobile number / email ID') {
			$(uname).val('');
		}
		if (pass.val() == 'Type password') {
			$(pass).val('');						
		}				
	});
/*Add Registration form action attribute*/
	 var reg_path = Drupal.settings.basePath + 'user/register';
	 $('form#user-register').attr('action',reg_path);
/*sign up  validation start */

$("#user-register").validate({
        rules: {         
          "field_first_name[0][value]":{
		  required: true,
		  depends:function (){			
				  if($('#edit-field-first-name-0-value').val()=='first name'){
					  $('#edit-field-first-name-0-value').val('');
					  return false;
				  }
			  }
		},
		"field_family_name[0][value]":{
		  required: true,
		  depends:function (){			
				  if($('#edit-field-family-name-0-value').val()=='family name'){
					  $('#edit-field-family-name-0-value').val('');
					  return false;
					  }				 
			  }
		},
		"field_district[0][value]":{
		  required: true,
		  depends:function (){			
				  if($('#edit-field-district-0-value').val()=='district name'){
					  $('#edit-field-district-0-value').val('');
					  return false;
					  }				 
			  }
		},
		mail:{
          required: true,
	      email:true
        }
		}
      });

	  function duplicate_chars(value,element)
    {
	  var s = value;
      var c1, c2 , c3;
      flag = 0;
      c1 = s.charAt(0);
      for(var i=1;i<s.length; i++){
     c2 = s.charAt(i);
	 c3 = s.charAt(i+1);
    if(c1 == c2 && c2 == c3)
	{
	flag = 1;
	}
    c1=c2;
	c2=c3;
}
if(flag)
{
 $(element).addClass('error');
 return false;
}		
}

$('div.signup_form input.signup_btn').click(function(){
 first = duplicate_chars($('#edit-field-first-name-0-value').val(),'#edit-field-first-name-0-value');
 family = duplicate_chars($('#edit-field-family-name-0-value').val(),'#edit-field-family-name-0-value');
 if(first){$('#edit-field-first-name-0-value').addClass('error');}
 if(family){$('#edit-field-family-name-0-value').addClass('error');}
 
});

 $.validator.addMethod("NumbersOnly", function(value, element) {													 
//         if(this.optional(element) || /^([0-9])}{10}$/i.test(value))
		r_mobile = /^(\d{10}){1}?$/;
		if(r_mobile.test(value))
		 {
			  return true;
		 }
    }, "Type 10 digit mobile number only");
	   	   $.validator.addMethod("ConfNumbers", function(value, element) {
														 if(value == $('#edit-field-mobile-0-value').val())
														 {
															 return true;}
    }, "Confirm Mobile number is not matched");
	   
	   
	   $.validator.addMethod("FirstName", function(value, element) {
												   first_name1 = /^[a-zA-Z]*$/;
												  
												   if(!first_name1.test(value))
												   {
													   if(value.length < 3)
													   {
														   return false;
														   }
													}
													 else{return true;}
    }, "Type your first(given) name");
	   
	   $.validator.addMethod("FamilyName", function(value, element) {
														 family_name1 = /^[a-zA-Z]*$/;														 
												   if(!family_name1.test(value))
												   {
													   if(value.length < 3)
													   {
														   return false;
														   }
													}
													 else{return true;}
    }, "Type your family name/surname");
	   
		var first_name = $('#edit-field-first-name-0-value');
		$(first_name).addClass('FirstName');
	  if ($(first_name).val() === "") {
		  
	       $(first_name).val('first name');
           }

		$(first_name).focus(function(){
		if (first_name.val() === 'first name') {
			$(first_name).val('');
		}
		});
		$(first_name).blur(function(){
		if (first_name.val() === '') {
				$(first_name).val('first name');
		}
		else if(first_name.val() != 'first name')
		{value = $(first_name).val();
			
			var r = duplicate_chars(value,'#edit-field-first-name-0-value');	

			if(r === false)
			{
				 $(first_name).val('first name');
			}
			}
		});

     var family_name = $('#edit-field-family-name-0-value');
	 $(family_name).addClass('FamilyName');
		  if ($(family_name).val() === "") {
	       $(family_name).val('family name');
           }
 
		$(family_name).focus(function(){
		if (family_name.val() == 'family name') {
			$(family_name).val('');
		}
		});
		$(family_name).blur(function(){
		if (family_name.val() === '') {
				$(family_name).val('family name');
		}
		else if(family_name.val() != 'family name')
		{value = $(family_name).val();
			var r = duplicate_chars(value,'#edit-field-family-name-0-value');			
			if(r === false)
			{
				 $(family_name).val('family name');
			}
			}
		});
		
		var mobile = $('#edit-field-mobile-0-value');
			$(mobile).addClass('NumbersOnly');
		  if ($(mobile).val() === "") {
	       $(mobile).val('type 10 digit mobile number');
           }
 
		$(mobile).focus(function(){
		if (mobile.val() == 'type 10 digit mobile number') {
			$(mobile).val('');
		}
		});
		$(mobile).blur(function(){
		if (mobile.val() === '') {
				$(mobile).val('type 10 digit mobile number');
		}
		});
		//var mobile = $('#edit-field-mobile-0-value');

		  if ($(mobile).val() === "") {
	       $(mobile).val('type 10 digit mobile number');
           }
 
		$(mobile).focus(function(){
		if (mobile.val() == 'type 10 digit mobile number') {
			$(mobile).val('');
		}
		});
		$(mobile).blur(function(){
		if (mobile.val() === '') {
				$(mobile).val('type 10 digit mobile number');
		}
		});
		var conf_mobile = $('#edit-field-conf-mobile-0-value');
		$(conf_mobile).addClass('NumbersOnly ConfNumbers');
		  if ($(conf_mobile).val() === "") {
	       $(conf_mobile).val('re-type 10 digit mobile number');
           }
 
		$(conf_mobile).focus(function(){
		if (conf_mobile.val() == 're-type 10 digit mobile number') {
			$(conf_mobile).val('');
		}
		});
		$(conf_mobile).blur(function(){
		if (conf_mobile.val() === '') {
				$(conf_mobile).val('re-type 10 digit mobile number');
		}
		});
		
		
		var email = $('#edit-mail');

		  if ($(email).val() === "") {
	       $(email).val('e.g. john@gmail.com');
           }
 
		$(email).focus(function(){
		if (email.val() == 'e.g. john@gmail.com') {
			$(email).val('');
		}
		});
		$(email).blur(function(){
		if (email.val() === '') {
				$(email).val('e.g. john@gmail.com');
		}
		});
		
		 var district = $('#edit-field-district-0-value');
		  if ($(district).val() === "") {
	       $(district).val('district name');
           }
 
		$(district).focus(function(){
		if (district.val() == 'district name') {
			$(district).val('');
		}
		});
		$(district).blur(function(){
		if (district.val() === '') {
				$(district).val('district name');
		}
		else if(district.val() != 'district name')
		{value = $(district).val();
			var r = duplicate_chars(value,'#edit-field-district-0-value');			
			if(r === false)
			{
				 $(district).val('district name');
			}
			}
		});
		
/*sign up  validation end */

/*forgot password start*/		 
		var frgt_mobile = $('div#forgot_pwd input#edit-mobile');
		var uname_f = $('div#forgot_pwd input#edit-name');
		if ($(uname_f).val()==="") {
				   $(uname_f).val('Type your email id');
				   }
		 
				$(uname_f).focus(function(){
				if ($(uname_f).val() == 'Type your email id') {
					$(uname_f).val('');
				}
				});
				$(uname_f).blur(function(){
				if (uname_f.val()==="") {
						$(uname_f).val('Type your email id');
				}
				});

				if ($(frgt_mobile).val()==="") {
				   $(frgt_mobile).val('Type your mobile number');
				   }
		 
				$(frgt_mobile).focus(function(){
				if ($(frgt_mobile).val() == 'Type your mobile number') {
					$(frgt_mobile).val('');
				}
				});
				$(frgt_mobile).blur(function(){
				if (frgt_mobile.val()==="") {
						$(frgt_mobile).val('Type your mobile number');
				}
				});
  /*forgot password End*/
};
